<template>
  <!-- 流程节点 -->
    <Card style="height:800px">
      <Content style="margin-top:20px;">
        <Table  border :columns="tableColumns" :data="tableDatas"></Table>
      </Content>
      <div>&nbsp;</div>
      <div style="text-align:center">
          <Button type="primary" @click="addFlowNodePage" >添加流程节点</Button>
      </div>
      <div style="text-align:center;width:50%;margin:100px auto;">
        <Page :total="totalPage" :current="pageNum" :page-size="pageSize" size="small" show-elevator show-sizer show-total @on-change="handlePageChange" @on-page-size-change="sizeChange"></Page>
      </div>
    </Card>
</template>

<script>

export default {

  data () {
    return {
      tableColumns: [
        {
          type: 'index',
          title: '序号'
        },
        {
          title: '流程节点代码',
          key: 'node_code'
        },
        {
          title: '流程节点名称',
          key: 'node_name'
        },
        {
          title: '备注',
          key: 'remark'
        },
        {
          title: '最近更新人',
          key: 'update_by'
        },
        {
          title: '最近更新时间',
          key: 'updated_date'
        }

      ],
      tableDatas: [ ],
      totalPage: 0,
      pageNum: 1,
      pageSize: 12
    }
  },
  methods: {
    addFlowNodePage () {
      this.$router.push({ name: 'flow_node_add', params: {} })// 类似post传参
    },
    handlePageChange: function (pageNum) {
      var vm = this
      vm.pageNum = pageNum
      vm.initPage()
    },
    sizeChange: function (pageLength) {
      var vm = this
      vm.pageSize = pageLength
      vm.initPage()
    },
    initPage (goPage) {
      var vm = this
      var params = { pageSize: vm.pageSize, pageNum: vm.pageNum }
      this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/flow_node/service/nlist', params).then(re => {
        this.tableDatas = []
        var datas = re.data.data.list || []
        this.totalPage = re.data.data.total
        datas.forEach(item => {
          var tData = {}
          tData.node_code = item.nodeCode
          tData.node_name = item.nodeName
          tData.remark = item.remark
          tData.update_by = item.updatedBy
          tData.updated_date = this.$util.formatTime(new Date(item.updatedDate))
          this.tableDatas.push(tData)
        })
      }).catch(er => {
      })
    }
  },
  created: function () {
    this.$ajax = this.$util.ajax()
    this.initPage()
  }
}
</script>

<style lang="less">

</style>
